package org.hugoduncan.appam.server.impl;

import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

import org.apache.abdera.model.Entry;
import org.hugoduncan.appam.model.Constants;
import org.hugoduncan.appam.server.AppServletResponse;

public class AppServletResponseImpl 
    extends HttpServletResponseWrapper
    implements AppServletResponse 
{
    private Entry entry;
    private String baseUrl;
    
    public String getBaseUrl() {
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public AppServletResponseImpl(HttpServletResponse response) {
        super(response);
    }

    public void send() throws IOException {
        if (entry!=null)
        {
            setCharacterEncoding("utf-8");
            setContentType(Constants.SC_ATOM_CONTENT_TYPE);    
            entry.getDocument().writeTo(getWriter());
            flushBuffer();
        }
    }

    public Entry getEntry() {
        return entry;
    }

    public void setEntry(Entry entry) {
        this.entry=entry;
    }

}
